clc
close ALL
clear ALL

num_lmk_sel = [60:10:140];
num_lmk_all = 200;
sz_rand_sam = [2, 4, 6, 8, 10, 12, 14, 16]';

%%
time_cost = [
  0.000606206 0.000595498 0.000727912 0.000643135 0.000778162 0.000589459 0.000579186 0.00056261 0.000510668
  0.000746488 0.000738437 0.000754363 0.000747575 0.000779005 0.000708676 0.000653854 0.00062335 0.000581106
  0.000897653 0.000898438 0.000922779 0.000928861 0.00094181 0.000831459 0.000787521 0.000713403 0.000648104
  0.00103649 0.00119734 0.00119668 0.00107743 0.00110714 0.000983171 0.00088869 0.000897865 0.000808279
  0.00120183 0.00122536 0.00122419 0.00120678 0.00123535 0.00108637 0.000955153 0.000879119 0.000777562
  0.00135844 0.00137264 0.00139553 0.00137816 0.00140674 0.00122973 0.00111902 0.000976165 0.000872989
  0.00145238 0.0015022 0.00152685 0.00151352 0.0015321 0.00133416 0.00116792 0.00101908 0.000921346
  0.00156627 0.00157207 0.0015878 0.00158787 0.00160835 0.00139179 0.00118192 0.00103323 0.000901398
  ];

diff_avg = [
  16.59 18.52 17.81 20.45 19.17 25.17 25.99 26.63 32.06
  8.01 9.09 8.69 10.19 9.6 11.49 14.52 15.39 17.96
  4.76 5.52 5.35 5.68 5.72 7.67 8.41 10.23 12.25
  3.48 3.64 4 4.2 4.17 5.25 6.33 7.58 8.93
  2.54 2.99 3.17 3.27 3.19 4.14 5.11 5.83 7.07
  2.19 2.21 2.25 2.65 2.61 3.35 3.8 4.8 5.45
  1.49 1.81 2.12 2.27 2.12 2.69 3.38 3.88 4.44
  1.36 1.66 1.57 1.75 1.72 2.17 2.85 3.16 4.01
  ];

diff_max = [
  21 26 24 26 25 32 32 33 39
  14 13 13 14 14 16 21 23 25
  9 10 10 11 10 12 13 15 17
  6 6 7 9 7 10 11 12 13
  5 6 6 6 6 7 9 9 11
  4 5 6 5 5 6 7 9 8
  4 4 5 5 5 6 6 7 8
  4 4 4 3 3 5 7 6 7
  ];

diff_min = [
  10 11 10 15 14 19 16 18 23
  4 5 4 6 5 6 9 9 10
  2 2 2 3 2 4 5 7 7
  1 1 2 2 1 2 2 3 5
  0 1 0 1 1 2 2 3 3
  1 1 0 0 1 1 1 2 2
  0 0 0 0 0 0 1 2 1
  0 0 0 0 0 0 1 1 1
  ];

%%
figure;
for i=1:length(num_lmk_sel)
  subplot(3, 3, i)
  errorbar(time_cost(:, i) * 1000, diff_avg(:, i), ...
    diff_avg(:, i) - diff_min(:, i), ...
    diff_max(:, i) - diff_avg(:, i));
  xlabel('ms')
  ylabel('diff. lmk')
  xlim([0.5 1.6])
  ylim([0 40])
  
  title([ num2str(num_lmk_sel(i)) '/' num2str(num_lmk_all) ])
end
